package com.company.project.service.impl;

import com.company.project.dao.SysFunctionMapper;
import com.company.project.model.SysFunction;
import com.company.project.service.SysFunctionService;
import com.company.project.core.AbstractService;
import org.apache.commons.lang3.StringUtils;
import org.omg.CORBA.OBJ_ADAPTER;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;


/**
 * Created by CodeGenerator on 2020/04/18.
 */
@Service
@Transactional
public class SysFunctionServiceImpl extends AbstractService<SysFunction> implements SysFunctionService {
    @Resource
    private SysFunctionMapper sysFunctionMapper;

    @Override
    public List<SysFunction> getFunctionListByRole(int roleId) {
        return sysFunctionMapper.getFunctionListByRole(roleId);
    }

    /**
     * 根据功能名称和类型查询列表
     *
     * @param functionName 功能名称
     * @param type         类型
     * @return
     */
    @Override
    public List<SysFunction> queryFunctionByFunctionNameAndType(String functionName, Integer type) {
        HashMap<String, Object> map = new HashMap<>();
        if (!StringUtils.isBlank(functionName)){
            map.put("functionName",functionName);
        }
        if (type != null){
            map.put("type",type);
        }
        return sysFunctionMapper.selectByCondition(map);
    }
}
